package com.ts.main.admin.controller;

import com.ts.main.admin.dto.AdminRoleDto;
import com.ts.main.admin.dto.AdminRoleSearchPageDto;
import com.ts.main.admin.dto.AdminSearchPageDto;
import com.ts.main.admin.exception.R;
import com.ts.main.admin.exception.RPage;
import com.ts.main.admin.service.AdminRoleServiceImpl;
import com.ts.main.admin.vo.AdminRoleVo;
import com.ts.main.admin.vo.AdminVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author:lk
 * @Date: 2025/6/9  16:50
 */
@AllArgsConstructor
@RestController
@RequestMapping("/role")
@Tag(name = "系统设置-角色管理")
public class AdminRoleController {

    private final AdminRoleServiceImpl adminRoleService;


    @PostMapping("/getRoleList")
    @Operation(summary = "查询角色列表")
    public RPage<List<AdminRoleVo>> getRolePage(@RequestBody AdminRoleSearchPageDto dto) {
        return adminRoleService.getRolePage(dto);
    }

    @GetMapping("/getRoleDetails")
    @Operation(summary = "查询角色详情")
    public R<AdminRoleVo> getRoleDetails(@Schema(description = "角色ID") @RequestParam Integer id) {
        return R.ok(adminRoleService.getRoleDetails(id));
    }

    @PostMapping("/saveRole")
    @Operation(summary = "添加角色")
    public R<Boolean> saveRole(@RequestBody AdminRoleDto dto) {
        return R.ok(adminRoleService.saveRole(dto));
    }

    @PutMapping("/updateRole")
    @Operation(summary = "修改角色")
    public R<Boolean> updateRole(@RequestBody AdminRoleDto dto) {
        return R.ok(adminRoleService.updateRole(dto));
    }

    @DeleteMapping("/deleteRole")
    @Operation(summary = "删除角色")
    public R<Boolean> deleteRole(@Schema(description = "角色ID") @RequestParam Integer id) {
        return R.ok(adminRoleService.deleteRole(id));
    }

}
